package com.vrland.web.front.service.impl;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import com.vrland.web.front.dto.User;
import com.vrland.web.front.repositories.spec.UserDao;
import com.vrland.web.front.service.spec.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao userDao;

	@Autowired
	private PasswordEncoder passwordEncoder;
	
	@Override
	public User createNewUser(User user) {
		String password = user.getPassword();
		user.setPassword(passwordEncoder.encode(password));
		return userDao.save(user);
	}

}
